function val = FOC_fossil_VF(x)

global parms i Sf kf Nf dVk_f T0 dVS
% Note that parms is a 1x14 vector with elements:
%
% parms = [delta A Sbar alpha0 alpha1 alpha2 alpha3 Gamma1 alpha psi beta gamma Q0 popgr];
%           1    2   3      4      5    6     7       8      9    10  11    12  13  14 

delta = parms(1);
A = parms(2);
Sbar = parms(3);
alpha0 = parms(4);
alpha1 = parms(5);
alpha2 = parms(6);
alpha3 = parms(7);
beta = parms(11);
gamma = parms(12);
popgr = parms(14);

k = x(1);
N = x(2);

Q = (1+popgr)^(T0-i+1);

c = (beta*dVk_f(i-1)).^(-1/gamma);
S = Sf(i-1)-Q*A*k;

g =  alpha0 + alpha1./(Sbar-alpha2./(alpha3+N)-S);
gdN = -alpha1.*alpha2./((Sbar-S).*(alpha3+N)-alpha2).^2;

val(1) = 1-g-delta/A+k*gdN+beta*c^gamma*dVS(i-1)*Q;
val(2) = A*k*(1-g)+(1-delta)*k+N-c-kf(i-1)-Nf(i-1);



